<?php
class user extends CI_Controller {
    
    function __construct()
	{
		parent::__construct();
                $this->load->library('session');
	}
        
        function allTahmins(){
            if($this->session->userdata('validated')){
                $this->load->model('membership_model');
                $data['kupon']=  $this->membership_model->getAllTahmins($this->session->userdata('id'));
                $data['thmnsr'] = $this->session->userdata('kadi'); 
                $data['base']= $this->config->item('base_url');
                $data['css']=  $this->config->item('css');
                $data['title']= 'Tahmins.com..';
                $data['page']='user/allTahmins.php';
                $this->load->view('page_view',$data);
            }else{
                redirect('/login/loginn');
            }
        }
        
        function myFollow(){
            if($this->session->userdata('validated')){
                
            }else{
                redirect('/login/loginn');
            }
        }
        
        function changePass(){
            if($this->session->userdata('validated')){
            $data['base']= $this->config->item('base_url');
            $data['css']=  $this->config->item('css');
            $data['title']= 'Tahmins.com..';
            $data['page']='user/changePassThmnsr.php';
            $this->load->view('page_view',$data); 
            }else{
                redirect('/login/loginn');
            }
        }
        
        function logOutTahmins(){
           if($this->session->userdata('validated')){
                $this->session->sess_destroy();
                redirect('/index/index'); 
            }else{
                redirect('/login/loginn');
            } 
        }
        
        function changePassword(){
           if($this->session->userdata('validated')){
                $this->load->library('form_validation');
          $this->form_validation->set_rules('current','Kullanıcı Adınız','trim|xss_clean|required|min_length[4]');
          $this->form_validation->set_rules('passwrd','Şifre','trim|required|min_length[3]');
          $this->form_validation->set_rules('repasswrd','Şifre','trim|required|min_length[3]|matches[passwrd]');
          if($this->form_validation->run() == FALSE){
            $data['base']= $this->config->item('base_url');
            $data['css']=  $this->config->item('css');
            $data['title']= 'Tahmins.com..';
            $data['page']='user/changePassThmnsr.php';
            $this->load->view('page_view',$data); 
          }else{
              $this->load->model('membership_model');
              if($query = $this->membership_model->pass_ctrl($this->session->userdata('id'))){
                $data['base']= $this->config->item('base_url');
                $data['css']=  $this->config->item('css');
                $data['title']= 'Tahmins.com..';
                $data['page']='user/changePassThmnsr.php';
                $data['errors'] = 'Şifreniz başarıyla değiştirildi.';
                $this->load->view('page_view',$data);
              }else{
                $data['base']= $this->config->item('base_url');
                $data['css']=  $this->config->item('css');
                $data['title']= 'Tahmins.com..';
                $data['page']='user/changePassThmnsr.php';
                $data['errors'] = 'Mevcut Şifrenizi hatalı girdiniz.Lütfen tekrar deneyiniz.';
                $this->load->view('page_view',$data);  
              }
              
          }
                 
            }else{
                redirect('/login/loginn');
            } 
        }
    
}
?>
